import React from "react";

export default class Count extends React.Component{
    state = {
        count: 0,
    };
    constructor(props){
        super(props);
        console.log(this.state.count);
    }
    componentDidMount(){
        console.log('挂载');
    }
    componentDidUpdate(){
        console.log('更新');
    }
    componentWillUnmount(){
        console.log('销毁');
    }
    onAdd(){
       this.setState({
            count: this.state.count + 1,
       });
    }
    render(){
        return(
            <div>
                { this.state.count }
                <button onClick={ this.onAdd.bind(this) }>+1</button>
            </div>
        )
    }
}
